package cn.iocoder.yudao.module.xkfz.controller.admin.excel;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.xkfz.domain.excel.entity.Standard;
import cn.iocoder.yudao.module.xkfz.domain.excel.po.StandardPo;
import cn.iocoder.yudao.module.xkfz.service.excel.StandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * @Description 标准
 * @Author ZWC
 * @Date 2024/5/13 13:38
 */
@RestController
@RequestMapping("standard")
public class StandardController {

    @Autowired
    private StandardService standardService;

    @PostMapping("importStandard")
    public CommonResult<Boolean> importStandard(@RequestParam("file") MultipartFile file,@RequestParam("year")  String year) throws IOException {
        List<Standard> list = ExcelUtils.read(file, Standard.class);
        return success(standardService.importStandard(list, year));
    }

    @GetMapping("selectPage")
    public CommonResult<PageResult<Standard>>  selectPage (StandardPo reqVO){
        return success(standardService.selectPage(reqVO));
    }
    @PostMapping("insert")
    public CommonResult<Boolean> insert(Standard standard){
        return success(standardService.insert(standard));
    }
    @PostMapping("update")
    public CommonResult<Boolean> update(Standard standard){
        return success(standardService.update(standard));
    }

    @PostMapping("delete")
    public CommonResult<Boolean> delete(String id){
        return success(standardService.delete(id));
    }
}
